let request = require("request");
//let url ='https://voice.baidu.com/act/newpneumonia/newpneumonia/?from=osari_aladin_banner';
let fs = require("fs");
//let url='https://api.gugudata.com/news/joke';
//let url ="https://api.gugudata.com/sms/mobileattribution/demo";
let yiqingapi="https://interface.sina.cn/news/wap/fymap2020_data.d.json";

// xpath 模块这个就能解析html 元素，但是页面实现方式会绕一点，可以使用正则(正则表达式)去匹配，

// 

//演示了get方式请求数据,模拟提交表单post提交
request.get(yiqingapi,{},function(err,result,body){
    if(err){
        console.log(err);
    }else{
        //console.log(body);
        //字符串怎么转成json格式？ JSON.parse
        let obj = JSON.parse(body);
        //console.log(obj.list)
        let list = obj.data.list;
        list.forEach(ele => {
            console.log(ele.name);
            console.log(ele.ename);
            console.log(ele.adddaily.city.name)
        });

    }
    //console.log(arguments);
    //fs.writeFileSync('./yiqing1.html',body);
    //http 协议，又没头信息？http协议请求都会发送头信息
});//get 就说明是ge get 请求通过url传递参数，请求有几种方式？常用两种 get post delete ........

